1. Field of the Invention
This invention relates to a method and apparatus for runtime remediation of object-code instructions in a computer program and, more particularly, to a method and apparatus for runtime remediation of date instructions in a computer program that is not year 2000 compliant.
2. Description of the Related Art
The so-called year 2000 problem, or millennium bug as it is sometimes referred to, has received considerable attention lately. The problem arises from the fact that date representations in programs, files, and databases often use a two-digit year (YY) value, representing the year 1998, for example, simply as xe2x80x9c98xe2x80x9d, with the century being understood. Programs that perform arithmetic or comparison operations on such dates may give incorrect or unexpected results when dealing with years after 1999, since the understanding as to the century may no longer be correct. Thus, a date reference of xe2x80x9c00xe2x80x9d for the year 2000 may be erroneously interpreted as referring to the year 1900. A program making such an erroneous interpretation may determine that a credit card expiring in the year xe2x80x9c00xe2x80x9d expired in the year 1900 or that a payment due in the year xe2x80x9c00xe2x80x9d was due in 1900, with unfortunate results.
Various remediation techniques have been proposed in the prior art, such as those described in U.S. Pat. No. 5,600,836 to Alter, U.S. Pat. No. 5,630,118 to Shaughnessy, U.S. Pat. No. 5,644,762 to Soeder, U.S. Pat. No. 5,668,989 to Mao, and U.S. Pat. No. 5,761,668 to Adamchick, all incorporated herein by reference. Perhaps the most straightforward technique is to modify the original source code (e.g., COBOL code) to change all two-digit year references to four-digit year references that cannot be misinterpreted. However, this is often impractical for several reasons, including the large repository of data files in the old format that often exist.
Various other, less radical techniques may be applied to either source code or object code. On such technique, described in U.S. Pat. No. 5,600,836, is called xe2x80x9cwindowingxe2x80x9d. In windowing, two-digit year references are still understood is referring to a 100-year range, but one that is offset to include the years of interest, for example, the range 1928-2027. In this example, two-digit year references in the range 0-27 are interpreted as referring to the period 2000-2027, while two-digit year references in the range 28-99 are interpreted as referring to the period 1928-1999. While this technique must be used with caution to ensure that the year dates being processed do not fall outside the given 100-year range, it permits the use of existing data files.
Another technique, operating on object code, is that used by RTX Time Warp, part of the HDS RTX (Run Time eXtensions) Environment available from Hitachi Data Systems. Preliminarily, an object-code program is scanned for Subtract and Compare instructions having date operands that are susceptible to year 2000 failure. Each such date instruction is replaced by a xe2x80x9c00xe2x80x9d op code, and an entry for the instruction, identifying the program, the instruction location, the instruction type and the date format, is made in a registration table. When encountered at execution time, the xe2x80x9c00xe2x80x9d op code causes a suspension of execution, resulting in a transfer of control to RTX Time Warp. RTX Time Warp then looks for the instruction in the registration table and executes it while taking an appropriate corrective action. Thus, if the registered instruction is a Subtract instruction and produces a negative result (for example, if an operand of 4 representing an interval of 4 years is subtracted from a date operand 02 representing the year 2002), RTX Time Warp adds 100 to the result. Similarly, if the registered instruction is a Compare instruction (for example, comparing the operands 98 and 02 representing the year dates 1998 and 2002), RTX
Time Warp determines whether the condition code resulting from the comparison operation should be reversed to produce a correct result.
While the HDS tool has the advantage of being usable in situations where source code is unavailable, it is relatively limited in its repertoire of instructions that can be remediated (Subtract and Compare instructions) as well as the remediation techniques that are available.
In general, the present invention contemplates a method and apparatus for runtime remediation of object-code instructions (such as date instructions that are not year 2000 compliant) in a computer program. Before runtime, a setup function of a program monitor locates each instruction to be remediated in a load module of a user program and overlays the instruction with a trap instruction. The address of the overlaid instruction is stored in a scan slot of a window control table (WCT). The text of the overlaid instruction is stored in a corresponding operand slot of the WCT along with control information including a set of flags and windowing and cycling parameters.
At runtime, upon decoding a trap instruction, the CPU transfers control to an instruction simulation function of the program monitor, preferably using the trap instruction described in the related application referred to above. Upon gaining control, the instruction simulation function searches the scan slots of the WCT for the one containing the address of the overlaid instruction. Upon finding the scan slot, the instruction simulation function performs an instruction simulation operation in accordance with the control information in the corresponding operand slot, then returns control to the user program. If an execute flag is not set, the instruction simulation function invokes a specified user routine without executing the overlaid instruction. If the execute flag is set, the instruction simulation function executes the overlaid instruction in a mode of operation determined by the remaining flags. In a windowing mode, one or both instruction operands are compared with a specified delimiter, and the instruction is executed as though a specified increment were added to the operand before performing the operation of the instruction if the operand is less than the delimiter. In a cycling mode, a specified increment is added to the result the instruction would otherwise produce if that result is less than zero.